package dp.test53;

/**
 * @author code_yc
 * @version 1.0
 * @date 2020/7/22 12:18
 */
public class Solution1 {

    public int maxSubArray(int[] nums) {
        int n = nums.length;
        int pre = nums[0], cur = 0;
        int ans = pre;
        for (int i = 1; i < n; i++) {
            cur = Math.max(nums[i], pre + nums[i]);
            if (cur > ans) ans = cur;
            pre = cur;
        }
        return ans;
    }
}
